//创建和配置路由器并暴露出来
//1、引入路由器
import Home from "@/page/Home.vue";
import Goods from "@/page/Goods.vue";
import Role from "@/page/Role.vue";
import User from "@/page/User.vue";
import { createRouter,createWebHashHistory,createWebHistory } from "vue-router";
import Product from "@/page/goods/Product.vue";
import Order from "@/page/goods/Order.vue";


//2、创建路由器
const router=createRouter({
    //路由器的工作模式，一共有两种：1、history模式，2、hash模式
    history:createWebHashHistory(),
    //配置路由关系
    routes:[
        {   
            //名称
            name:'home',
            //路径 --- key
            path:'/home',
            //组件 --- value
            component:Home,
        },
        {
            //名称
            name:'user',
            //路径
            path:'/user',
            //组件
            component:User,
        },
        {
            //名称
            name:'role',
            //路径
            path:'/role',
            //组件
            component:Role,
        },
        {
            name:'goods',
            path:'/goods',
            component:Goods,
            children:[
                {   
                    name:'product',
                    //嵌套路由，子路由的path值是不加/
                    path:'product',
                    component:Product
                },
                {   
                    name:'order',
                    //嵌套路由，子路由的path值是不加/
                    path:'order',
                    component:Order
                }
            ]
        }
    ]
})
//3.把路由器暴露出来
export default router;